//
//  XTGeomancyDetailViewController.m
//  BeautifulHome
//
//  Created by dlios on 15-5-14.
//  Copyright (c) 2015年 ACE. All rights reserved.
//

#import "XTGeomancyDetailViewController.h"
#import "AFNetworking.h"
#import "TFHpple.h"
@interface XTGeomancyDetailViewController ()<UIWebViewDelegate>
@property (nonatomic, retain) UIWebView *web;
@property (nonatomic , strong) TFHpple *httpCode;
@end

@implementation XTGeomancyDetailViewController

- (void)dealloc
{
    [_web release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = self.geomancy.title;
    self.web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 95)];
    NSString *str1 = @"font-size:15px;";
    NSString *str2 = @"font-size:20px;";
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *str = [NSString stringWithFormat:@"http://www.to8to.com/mobileapp/xnjz/index.php?controller=fengshui&action=info&type=1&kid=%@",self.geomancy.kid];
    [manager GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSString *str = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
        NSLog(@"%@", str);
        NSString *str3 = [str stringByReplacingOccurrencesOfString:@"font-size:48px;" withString:str1];
        NSString *str4 = [str3 stringByReplacingOccurrencesOfString:@"font-size:58px;" withString:str2];
        [_web loadHTMLString: str4 baseURL: [NSURL fileURLWithPath: [[NSBundle mainBundle]  bundlePath]]];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
    
    [self.view addSubview:_web];
    _web.delegate = self;
    [_web release];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
